﻿using DevExpress.XtraBars;
using DevExpress.XtraTab;
using DXApplicationTangche.service;
using DXApplicationTangche.UC.下单MTO;
using DXApplicationTangche.UC.套号管理;

using DXApplicationTangche.UC.CRM;

//using DXApplicationTangche.UC.客户CRM;
using DXApplicationTangche.UC.成品出库单;
using DXApplicationTangche.UC.标签打印;
using DXApplicationTangche.UC.生产计划.生产批生产;

using DXApplicationTangche.UC.盘点;
using DXApplicationTangche.UC.订单;
using DXApplicationTangche.UC.订单一览新.辅料.辅料管理;
using DXApplicationTangche.UC.货号管理;
using DXApplicationTangche.UC.销售台账;
using DXApplicationTangche.UC.销售管理;
using DXApplicationTangche.UC.门店下单.form;
using DXApplicationTangche.UC.门店出入库;
using DXApplicationTangche.UC.门店出入库.淘宝;
using DXApplicationTangche.UC.面料库存;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DXApplicationTangche.UC.已开立看板;
using DXApplicationTangche.UC.生产下单;
using DXApplicationTangche.UC.订单一览新.销售确认单;
using DXApplicationTangche.UC.订单一览新.客户充值;
using DXApplicationTangche.UC.订单一览新.对账;
using DXApplicationTangche.UC.流程;
using DXApplicationTangche.UC.抖音出入库;
using DXApplicationTangche.UC.面料审核;
using System.IO;
using DXApplicationTangche.UC.客户管理;
using DXApplicationTangche.UC.抖音出入库.抖音UC;
using DXApplicationTangche.UC.金蝶;
using DXApplicationTangche.UC.工序管理.工序门户;
using DXApplicationTangche.UC.有赞.有赞商品;
using DXApplicationTangche.UC.报表;
using DXApplicationTangche.UC.纳客;

namespace DXApplicationTangche
{
    public partial class FluentDesignFormMTO : DevExpress.XtraBars.FluentDesignSystem.FluentDesignForm
    {
        public FluentDesignFormMTO()
        {
            InitializeComponent();
            FormMTO定制下单 form = new FormMTO定制下单();
            form.addTabDataEvents += this.addTab;
            this.initPanel(form);
            //this.initPanel(new FormMTO定制下单());
            this.initPanelsale(new FormMTO团体套号下单());
            ResourceService.synPictureResouces();

            //进入Form保存抖音excel模板
            byte[] buffer = Properties.Resources.抖音出库单;//获取嵌入dll文件的字节数组  
            string strPath = Application.StartupPath + @"\tag\" + "抖音出库单.xlsx";//设置释放路径   导出路径
                                                                               //创建dll文件（覆盖模式）  
            using (FileStream fs = new FileStream(strPath, FileMode.Create))
            {
                fs.Write(buffer, 0, buffer.Length);
            }

            //进入Form保存生产计划视图excel模板
            byte[] bufferMrp = Properties.Resources.生产计划视图;//获取嵌入dll文件的字节数组  
            string strPathMrp = Application.StartupPath + @"\tag\" + "生产计划视图.xlsx";//设置释放路径   导出路径
                                                                                   //创建dll文件（覆盖模式）  
            using (FileStream fs = new FileStream(strPathMrp, FileMode.Create))
            {
                fs.Write(bufferMrp, 0, bufferMrp.Length);
            }

            //进入Form保存进出库明细excel模板
            byte[] bufferInout = Properties.Resources.进出库明细;//获取嵌入dll文件的字节数组  
            string strPathInout = Application.StartupPath + @"\tag\" + "进出库明细.xlsx";//设置释放路径   导出路径
                                                                                    //创建dll文件（覆盖模式）  
            using (FileStream fs = new FileStream(strPathInout, FileMode.Create))
            {
                fs.Write(bufferInout, 0, bufferInout.Length);
            }
        }
        private void addTab(Form form)
        {
            XtraTabPage newTabPage = new XtraTabPage();
            newTabPage.Name = "详情";//设置新TabPage的Name
            newTabPage.Text = "详情";//设置新TabPage的标题文本
            form.TopLevel = false;
            xtraTabControl主页面.TabPages.Add(newTabPage);//添加
            xtraTabControl主页面.SelectedTabPage = newTabPage;//设置为选中
            newTabPage.Controls.Add(form);
            form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            form.Dock = System.Windows.Forms.DockStyle.Fill;
            form.Show();

        }
        private void initPanel(Form frm)
        {
            this.xtraTabPageMain.Controls.Clear();
            //指示窗体显示是否为顶级窗口
            frm.TopLevel = false;
            this.xtraTabPageMain.Controls.Add(frm);
            frm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            frm.Dock = System.Windows.Forms.DockStyle.Fill;
            frm.Show();
        }
        private void initPanelsale(Form frm)
        {
            this.xtraTabPage销售订单一览.Controls.Clear();
            //指示窗体显示是否为顶级窗口
            frm.TopLevel = false;
            this.xtraTabPage销售订单一览.Controls.Add(frm);
            frm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            frm.Dock = System.Windows.Forms.DockStyle.Fill;
            frm.Show();
            // 最新登记货号
            XtraUserControl样衣最新货号 XtraUserControl样衣最新货号 = new XtraUserControl样衣最新货号();
            this.xtraTabPage最新登记货号.Controls.Clear();
            this.xtraTabPage最新登记货号.Controls.Add(XtraUserControl样衣最新货号);
            XtraUserControl样衣最新货号.Dock = System.Windows.Forms.DockStyle.Fill;
            XtraUserControl样衣最新货号.Show();
        }
        private void accordionControlElement春衫定制_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form销售门户());
            //this.initPanel(new Frm门店统一下单());
            //new Frm门店统一下单().ShowDialog();
        }
        /// <summary>
        /// 客户套号
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void accordionControlElement团体套号_Click(object sender, EventArgs e)
        {
            //this.initPanel(new FormMTO团体套号下单());
            this.initPanel(new FormMTO订单分录("客户套号"));
        }

        private void accordionControlElement订单一览_Click(object sender, EventArgs e)
        {
            //this.initPanel(new FormMTO销售订单一览());
            this.initPanel(new FormMTO团体套号下单());
        }

        private void accordionControlElement客户一览_Click(object sender, EventArgs e)
        {
            this.initPanel(new UC.CRM.FormCRM客户一览());
        }

        private void accordionControlElement套号补货_Click(object sender, EventArgs e)
        {
            this.initPanel(new FormMTO订单分录("套号下单"));
        }

        private void accordionControlElement套号订单一览_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form套号门户());
        }

        private void accordionControlElement定制订单一览_Click(object sender, EventArgs e)
        {
            FormMTO定制下单 form = new FormMTO定制下单();
            form.addTabDataEvents += this.addTab;
            this.initPanel(form);
        }

        private void accordionControlElement淘宝发运_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form淘宝发运());
        }

        private void accordionControlElement门店出入库_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form门店出入库());
        }

        private void accordionControlElement返修订单一览_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form返修订单一览("18"));
        }

        private void accordionControlElement面料查询_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form进销存门户());
        }

        private void accordionControlElement辅料查询_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form辅料一览());
        }

        private void accordionControlElement样衣登记一览_Click(object sender, EventArgs e)
        {
            this.initPanel(new FormMTO样衣登记一览());
        }

        private void accordionControlElement盘点一览_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form盘点计划一览());
        }

        private void xtraTabControl主页面_CloseButtonClick(object sender, EventArgs e)
        {
            DevExpress.XtraTab.ViewInfo.ClosePageButtonEventArgs EArg = (DevExpress.XtraTab.ViewInfo.ClosePageButtonEventArgs)e;
            string name = EArg.Page.Text;//得到关闭的选项卡的text
            foreach (XtraTabPage page in this.xtraTabControl主页面.TabPages)//遍历得到和关闭的选项卡一样的Text
            {
                if (page.Text == name)
                {
                    if (page.Text.Equals("主页面")
                        || page.Text.Equals("辅料查询")
                        || page.Text.Equals("客户查询")
                        || page.Text.Equals("样衣登记一览")
                        || page.Text.Equals("最新登记货号")
                        || page.Text.Equals("销售订单一览")
                        )
                    {
                        return;
                    }
                    this.xtraTabControl主页面.TabPages.Remove(page);
                    page.Dispose();
                    return;
                }
            }
        }


        private void accordionControlElementCRM客户一览_Click(object sender, EventArgs e)
        {
            this.initPanel(new FormCRM客户一览());
        }
        private void accordionControlElement下单_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form套号门户());
        }

        private void accordionControlElement销售确认_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form销售台账("套号"));
        }

        private void accordionControlElement已开立_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form已开立("套号"));
        }

        private void accordionControlElement打水洗_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form水洗标());
        }

        private void accordionControlElement成品出库单_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form成品出库单());

        }

        private void accordionControlElement已开立看板_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form已开立看板());
        }

        private void accordionControlElement工厂向门店调拨勾稽校验_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form工厂向门店调拨勾稽校验("工厂调拨门店"));
        }

        private void accordionControlElement门店调拨勾稽校验_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form工厂向门店调拨勾稽校验("门店调拨"));
        }

        private void accordionControlElement销售整合下单_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form销售确认下单());
        }

        private void accordionControlElement销售整合确认_Click(object sender, EventArgs e)
        {
            this.initPanel(new FormMTO销售一览());
        }

        private void accordionControlElement客户一览_Click_1(object sender, EventArgs e)
        {
            this.initPanel(new Form客户一览带标签());
        }

        private void accordionControlElement定制待确认一览_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form待补充定制一览());
        }

        private void accordionControlElement会员预存_Click(object sender, EventArgs e)
        {
            //this.initPanel(new Form客户充值());
            this.initPanel(new Form会员预存());
        }

        private void accordionControlElement客户消费凭证_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form销售日记账视图一览());
        }

        private void accordionControlElement销售日结账单_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form销售日结账单());
        }

        private void accordionControlElement其他返厂确认_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form其他返厂确认());
        }

        private void accordionControlElement销售统计_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form销售统计());
        }

        private void accordionControlElement抖音套号下单_Click(object sender, EventArgs e)
        {
            //this.initPanel(new Form抖音款式添加());
            new Form抖音款式添加().ShowDialog();
        }

        private void accordionControlElement生产计划单产成品_Click(object sender, EventArgs e)
        {
            //this.initPanel(new Form生产计划单产成品());
            new Form生产计划单产成品().ShowDialog();
        }

        private void accordionControlElement客户积分一览_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form会员积分());
        }

        private void accordionControlElement抖音订单明细_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form抖音订单明细());
        }

        private void accordionControlElement抖音SKU一览_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form抖音sku一览());
        }

        private void accordionControlElement款式BOM明细及在途信息_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form款式BOM及在途信息());
        }

        private void accordionControlElement最新登记样衣一览_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form样衣最新登记货号());
        }

        private void accordionControlElement抖音生产计划_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form抖音生产计划());
        }

        private void accordionControlElement成衣工序扫码情况_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form成衣工序扫码情况());
        }

        private void accordionControlElement抖音直播间看板_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form抖音直播间看板());
        }

        private void accordionControlElement有赞SKU_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form有赞SKU());
        }

        private void accordionControlElement最新库存_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form最新库存());
        }

        private void accordionControlElement库存明细一览_Click(object sender, EventArgs e)
        {
            this.initPanel(new Form新建报表());
        }
    }
}
